import 'package:cbec_app/generated/json/base/json_convert_content.dart';
import 'package:cbec_app/entity/home/content/red_packet_decoration_entity.dart';

RedPacketDecorationEntity $RedPacketDecorationEntityFromJson(Map<String, dynamic> json) {
  final RedPacketDecorationEntity redPacketDecorationEntity = RedPacketDecorationEntity();
  final int? layout = jsonConvert.convert<int>(json['layout']);
  if (layout != null) {
    redPacketDecorationEntity.layout = layout;
  }
  final String? hideEmptyCoupon = jsonConvert.convert<String>(json['hide_empty_coupon']);
  if (hideEmptyCoupon != null) {
    redPacketDecorationEntity.hideEmptyCoupon = hideEmptyCoupon;
  }
  final List<RedPacketDecorationRedPacket>? redPacket = (json['red_packet'] as List<dynamic>?)?.map((e) => jsonConvert.convert<RedPacketDecorationRedPacket>(e) as RedPacketDecorationRedPacket).toList();
  if (redPacket != null) {
    redPacketDecorationEntity.redPacket = redPacket;
  }
  final int? couponStyle = jsonConvert.convert<int>(json['coupon_style']);
  if (couponStyle != null) {
    redPacketDecorationEntity.couponStyle = couponStyle;
  }
  final String? uuid = jsonConvert.convert<String>(json['uuid']);
  if (uuid != null) {
    redPacketDecorationEntity.uuid = uuid;
  }
  return redPacketDecorationEntity;
}

Map<String, dynamic> $RedPacketDecorationEntityToJson(RedPacketDecorationEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['layout'] = entity.layout;
  data['hide_empty_coupon'] = entity.hideEmptyCoupon;
  data['red_packet'] = entity.redPacket?.map((v) => v.toJson()).toList();
  data['coupon_style'] = entity.couponStyle;
  data['uuid'] = entity.uuid;
  return data;
}

extension RedPacketDecorationEntityExtension on RedPacketDecorationEntity {
  RedPacketDecorationEntity copyWith({
    int? layout,
    String? hideEmptyCoupon,
    List<RedPacketDecorationRedPacket>? redPacket,
    int? couponStyle,
    String? uuid,
  }) {
    return RedPacketDecorationEntity()
      ..layout = layout ?? this.layout
      ..hideEmptyCoupon = hideEmptyCoupon ?? this.hideEmptyCoupon
      ..redPacket = redPacket ?? this.redPacket
      ..couponStyle = couponStyle ?? this.couponStyle
      ..uuid = uuid ?? this.uuid;
  }
}

RedPacketDecorationRedPacket $RedPacketDecorationRedPacketFromJson(Map<String, dynamic> json) {
  final RedPacketDecorationRedPacket redPacketDecorationRedPacket = RedPacketDecorationRedPacket();
  final String? getLimit = jsonConvert.convert<String>(json['getLimit']);
  if (getLimit != null) {
    redPacketDecorationRedPacket.getLimit = getLimit;
  }
  final String? discountDetails = jsonConvert.convert<String>(json['discountDetails']);
  if (discountDetails != null) {
    redPacketDecorationRedPacket.discountDetails = discountDetails;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    redPacketDecorationRedPacket.name = name;
  }
  final int? surplusNum = jsonConvert.convert<int>(json['surplusNum']);
  if (surplusNum != null) {
    redPacketDecorationRedPacket.surplusNum = surplusNum;
  }
  final String? couponId = jsonConvert.convert<String>(json['couponId']);
  if (couponId != null) {
    redPacketDecorationRedPacket.couponId = couponId;
  }
  final String? marketingId = jsonConvert.convert<String>(json['marketingId']);
  if (marketingId != null) {
    redPacketDecorationRedPacket.marketingId = marketingId;
  }
  final String? goodsType = jsonConvert.convert<String>(json['goodsType']);
  if (goodsType != null) {
    redPacketDecorationRedPacket.goodsType = goodsType;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    redPacketDecorationRedPacket.status = status;
  }
  return redPacketDecorationRedPacket;
}

Map<String, dynamic> $RedPacketDecorationRedPacketToJson(RedPacketDecorationRedPacket entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['getLimit'] = entity.getLimit;
  data['discountDetails'] = entity.discountDetails;
  data['name'] = entity.name;
  data['surplusNum'] = entity.surplusNum;
  data['couponId'] = entity.couponId;
  data['marketingId'] = entity.marketingId;
  data['goodsType'] = entity.goodsType;
  data['status'] = entity.status;
  return data;
}

extension RedPacketDecorationRedPacketExtension on RedPacketDecorationRedPacket {
  RedPacketDecorationRedPacket copyWith({
    String? getLimit,
    String? discountDetails,
    String? name,
    int? surplusNum,
    String? couponId,
    String? marketingId,
    String? goodsType,
    int? status,
  }) {
    return RedPacketDecorationRedPacket()
      ..getLimit = getLimit ?? this.getLimit
      ..discountDetails = discountDetails ?? this.discountDetails
      ..name = name ?? this.name
      ..surplusNum = surplusNum ?? this.surplusNum
      ..couponId = couponId ?? this.couponId
      ..marketingId = marketingId ?? this.marketingId
      ..goodsType = goodsType ?? this.goodsType
      ..status = status ?? this.status;
  }
}
